#ifndef _YATAK_IP_H
#define _YATAK_IP_H

#include <net/buff.h>

struct s_iphdr
{
	unsigned char ihl:4,
				version:4;
	unsigned char tos;
	unsigned short tot_len;
	unsigned short id;
	unsigned short frag_off;
	unsigned char ttl;
	unsigned char protocol;
	unsigned short check;
	unsigned long saddr;
	unsigned long daddr;
	//The options start here.
};

#define ICMP_ECHOREPLY		0		// Echo Reply			
#define ICMP_DEST_UNREACH	3		// Destination Unreachable	
#define ICMP_SOURCE_QUENCH	4		// Source Quench		
#define ICMP_REDIRECT		5		// Redirect (change route)	
#define ICMP_ECHO			8		// Echo Request			
#define ICMP_TIME_EXCEEDED	11		// Time Exceeded		
#define ICMP_PARAMETERPROB	12		// Parameter Problem		
#define ICMP_TIMESTAMP		13		// Timestamp Request		
#define ICMP_TIMESTAMPREPLY	14		// Timestamp Reply		
#define ICMP_INFO_REQUEST	15		// Information Request		
#define ICMP_INFO_REPLY		16		// Information Reply		
#define ICMP_ADDRESS		17		// Address Mask Request		
#define ICMP_ADDRESSREPLY	18		// Address Mask Reply		


// Codes for UNREACH. 
#define ICMP_NET_UNREACH	0		// Network Unreachable		
#define ICMP_HOST_UNREACH	1		// Host Unreachable		
#define ICMP_PROT_UNREACH	2		// Protocol Unreachable		
#define ICMP_PORT_UNREACH	3		// Port Unreachable		
#define ICMP_FRAG_NEEDED	4		// Fragmentation Needed/DF set	
#define ICMP_SR_FAILED		5		// Source Route failed		
#define ICMP_NET_UNKNOWN	6
#define ICMP_HOST_UNKNOWN	7
#define ICMP_HOST_ISOLATED	8
#define ICMP_NET_ANO		9
#define ICMP_HOST_ANO		10

struct s_icmphdr
{
	unsigned char type;
	unsigned char code;
	unsigned short checksum;
};

/* Display an IP address in readable format.*/
char *in_ntoa(unsigned long in);

unsigned long in_aton(const char *str);

/*
 * This routine builds the appropriate hardware/IP headers for
 * the routine.
 *
 * Warning! There must already be a ARP Entry for the destination IP address.
 */
//struct s_net_buff* ip_build_header(unsigned long saddr, unsigned long daddr, struct s_net_device *dev, int type, int len, int tos, int ttl);

void ip_send_check(struct s_iphdr *iph);
/*
 * This routine does all the checksum computations that don't
 * require anything special (like copying or special headers).
 */
unsigned short ip_compute_csum(unsigned char * buff, int len);

/************************************************************************/
/* Entry point from net for all received IP packets.                    */
/************************************************************************/
//int ip_rcv(struct s_net_buff *buff, struct s_net_device *dev);

#endif
